﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebsiteAdmin.Wilson.News
{
    public partial class NewsList : System.Web.UI.Page
    {
        public int countPage;
        public int countRow;
        public int pageSize = Global.PageSize;
        public int pageIndex = 1;
        public string whereStr = "WHERE [Valid] = 1";
        public string urlStr = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request["page"] != null && Request["page"] != "")
                    pageIndex = Convert.ToInt32(Request["page"].ToString());

                Bll.DataGroup dtNews = Bll.News.MULTIPLE(Global.ConnWilson, pageSize, pageIndex, whereStr);

                if (dtNews.DT.Rows.Count > 0)
                {
                    this.RP_News.DataSource = dtNews.DT.DefaultView;
                    this.RP_News.DataBind();
                }
                Pagination.ProcessPageToHtml(pageSize, pageIndex, urlStr, dtNews.Row, dtNews.Page);
                dtNews.Dispose();
            }
            else
            {
                Response.Redirect("/Trace.aspx?Err=1");
            }
        }
    }
}
